<?
/*
 *  GGB - Gelin's Guest Book.
 *  Copyright (C) 2006-2009 Denis Nelubin aka Gelin
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  http://gelin.ru
 *  mailto:den@gelin.ru
 *
 *  Description:    Action, prepares data for viewing posts, and includes aproppriate templates.
 *
 *  History:
 *  2006-08-20  Gelin   Initially created.
 *  2007-07-04  Gelin   Task #6  Add a posibility to view deleted messages in admin interface.
 *                      - copied and modified from admin-view action
 *  2009-10-14  Gelin   Modified to use message type
 *
 */

$messageType = NEW_MESSAGE;

$format->setMessageType($messageType);

//get page
$currentPage = getParameter('page');
if (!isset($currentPage)) {
    $currentPage = 0;
}
$pages = $format->preparePages($currentPage, $storage->getNumberOfPages($messageType));

//get messages
$dbMessages = $storage->getMessagesForPage($currentPage, $messageType);
$messages = array();
foreach ($dbMessages as $message) {
    $messages[] = $format->prepareToDisplay($message);
}
unset($dbMessages);

//prepare form
$form = $format->prepareForm(); //view page can contain form for new message

include($config['template']['admin_view_new']);

?>